package gengduo;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.jizhangben.R;
import com.example.jizhangben.databinding.ActivityWeiXinGenDuoBinding;

import java.util.ArrayList;
import java.util.List;

import fragment.WeiXInZhiChuBean;

public class WeiXinGenDuo extends AppCompatActivity {
    private ActivityWeiXinGenDuoBinding binding;
    private RecyclerView view;
    private List<WeiXInZhiChuBean> date;
    private List<WeiXInZhiChuBean> newdate;

    @RequiresApi(api = Build.VERSION_CODES.N)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityWeiXinGenDuoBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        getSupportActionBar().setTitle("更多记录");
        date = (List<WeiXInZhiChuBean>) getIntent().getSerializableExtra("date");
        newdate = new ArrayList<>();
        newdate.addAll(date);
        Log.e("传递过来的数据", newdate.toString());

        view = binding.jilu;
        view.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));

        view.setAdapter(new RecyclerView.Adapter<MyHoled>() {
            @NonNull
            @Override
            public MyHoled onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                View view = View.inflate(parent.getContext(), R.layout.weixin_idem, null);
                return new MyHoled(view);

            }

            @SuppressLint("SetTextI18n")
            @Override
            public void onBindViewHolder(@NonNull MyHoled holder, int position) {
                holder.t1.setText("时间" + newdate.get(position).getTime());
                holder.t2.setText(newdate.get(position).getDidian());
                holder.t3.setText(newdate.get(position).getMoney() + "元");
                holder.t4.setText("备注" + newdate.get(position).getBeizhu());
            }


            @Override
            public int getItemCount() {
                return newdate.size();
            }
        });


    }

    public class MyHoled extends RecyclerView.ViewHolder {
        TextView t1, t2, t3, t4;

        public MyHoled(@NonNull View itemView) {
            super(itemView);
            t1 = itemView.findViewById(R.id.sj);
            t2 = itemView.findViewById(R.id.dd);
            t3 = itemView.findViewById(R.id.xf);
            t4 = itemView.findViewById(R.id.bz);
        }
    }
}